package xyz.xmh.pattern.creational.abstractfactorypattern;

import xyz.xmh.pattern.creational.abstractfactorypattern.inter.Color;
import xyz.xmh.pattern.creational.abstractfactorypattern.inter.Shape;
import xyz.xmh.pattern.creational.abstractfactorypattern.inter.impl.Circle;
import xyz.xmh.pattern.creational.abstractfactorypattern.inter.impl.Rectangle;
import xyz.xmh.pattern.creational.abstractfactorypattern.inter.impl.Square;

/**
 * ShapeFactory
 *
 * @author xuMingHai
 * @since 2021/4/27 星期二 16:06
 */
public class ShapeFactory extends AbstractFactory {

    /**
     * 圆圈
     */
    private static final String CIRCLE = "CIRCLE";

    /**
     * 长方形
     */
    private static final String RECTANGLE = "RECTANGLE";

    /**
     * 正方形
     */
    private static final String SQUARE = "SQUARE";

    @Override
    public Color getColor(String colorType) {
        return null;
    }

    /**
     * 根据形状类型，生成具体的对象,<br/>
     * 参数为空，形状类型不存在,返回的对象是null
     *
     * @param shapeType 形状类型
     * @return 具体的形状对象
     */
    @Override
    public Shape getShape(String shapeType) {
        if (shapeType == null) {
            return null;
        }
        if (shapeType.equalsIgnoreCase(CIRCLE)) {
            return new Circle();
        }
        else if (shapeType.equalsIgnoreCase(RECTANGLE)) {
            return new Rectangle();
        }
        else if (shapeType.equalsIgnoreCase(SQUARE)) {
            return new Square();
        }
        return null;
    }

}
